home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-08-01 | 2.3 KB | 83 lines | [TEXT/CWIE] |
- BSDFileLib v1.0.2
- BuggySoft™ Development
- By Scott Dunbar.
- © 1997.
-
- email: buggysft@aimnet.com
- web: http://www.aimnet.com/~buggysft/
- ftp: ftp://ftp.aimnet.com/pub/users/buggysft/
-
- BSDFileLib is a CodeWarrior 11 library that I made for my own use in a game of ours
- called Torture Chamber. You can use this lib free of charge. With this, you can easily read from
- and write to a file.
- Call this lib like this:
-
- // To Read From A File…
- {
- Handle fileData; // Handle to the file data
- short vRefNum; // the refNum of the current volume
- long dirID; // the parent id of the application (just for this example)
-
- fileData = NewHandle(0); // create an empty handle
- HLock(fileData); // lock it
-
- HGetVol(nil, vRefNum, dirID); // get the vRefNum and dirID (where the file is)
- ReadFile(vRefNum, dirID, "\pMy File", fileData); // read in the file data
-
- // do something with the fileData…
-
- HUnlock(fileData); // unlock the handle
- DisposeHandle(fileData); // dispose of it
- }
-
- // To Write To A File…
- {
- Handle fileData; // Handle to the file data
- short vRefNum; // the refNum of the current volume
- long dirID; // the parent id of the application (just for this example)
-
- fileData = NewHandle(0); // create an empty handle
- HLock(fileData); // lock it
-
- HGetVol(nil, vRefNum, dirID); // get the vRefNum and dirID (where the file is)
- WriteFile(vRefNum, dirID, "\pMy File", 'test', 'DATA', fileData);
-
- HUnlock(fileData); // unlock the handle
- DisposeHandle(fileData); // dispose of it
- }
-
- // To Read From A Preferences File…
- {
- Handle prefsData; // Handle to the file data
-
- prefsData = NewHandle(0); // create an empty handle
- HLock(prefsData); // lock it
-
- ReadPrefsFile("\pMy Prefs", prefsData); // read in the pref file data
-
- // do something with the prefsData…
-
- HUnlock(prefsData); // unlock the handle
- DisposeHandle(prefsData); // dispose of it
- }
-
- // To Write To A Preferences File…
- {
- Handle prefsData; // Handle to the file data
-
- prefsData = NewHandle(0); // create an empty handle
- HLock(prefsData); // lock it
-
- WritePrefsFile("\pMy Prefs", 'myap', prefsData);
-
- HUnlock(prefsData); // unlock the handle
- DisposeHandle(prefsData); // dispose of it
- }
-
- Those examples will work, but they are pretty much useless.
-
- Check out the header, "BSDFileLib.h," for more info on them.
- If you would like an example of this lib being used, email me and I'll throw one together.
-
- Thanks!
- - Scott Dunbar